import React from 'react';
import gql from 'graphql-tag';
import {connect} from 'react-apollo';
import {Row} from 'antd';
import Hello from './hello';

const mapQueriesToProps = () => ({
    data: {
        query: gql`
            query {
                hello {
                    text
                    index
                }
            }
        `
    }
});

const mapMutationsToProps = () => ({
    setHello: (args) => ({
        mutation: gql`
            mutation set($delta: Int!) {
                setHello(delta: $delta)
            }
        `,
        variables: {
            delta: args.delta
        }
    })
});

const HelloConnected = connect({
    mapQueriesToProps,
    mapMutationsToProps
})(Hello);

export default () => (
    <Row type="flex" justify="center">
        <HelloConnected/>
    </Row>
);
